import { request } from './request'
const src="https://theo-666-1313960509.cos.ap-shanghai.myqcloud.com"
export default {
    src
}
//超时提交
export function timeOut(gid){
    return request({
        url:"/check/product-serv/goodstwo/msfailure",
        data:{
            goodid:gid,
        },
        method:"post"
    })
}
//评价
    export function putEva(message,gid,uuid){
        return request({
            url:"/check/order-serv/orders/addEva",
            data:{
                message:message,
                goodsId:gid,
                uuid:uuid
            },
            method:"put"
        })
    }
//修改地址
    export function updateAddress(uuid,addressId){
        return request({
            url:"/check/order-serv/orders/modifyAddress",
            data:{
                uuid:uuid,
                addressId:addressId
            },
            method:"post"
        })
    }
//退款
    export function putRefund(uuid,cause,price){
        return request({
            url:"/check/pay-serv/alipay/refund",
            data:{
                uuid:uuid,
                refundMsg:cause,
                refundPrice:price,
            },
            method:"put"
        })
    }
//轮询
export function getSelectUuid(uuid){
    return request({
    url:"/check/order-serv/orders/selectUuid",
    data:{
        uuid:uuid
    },
    method:"post"
})
}
//登录模块
export function getSms(phone) {
    return request({
        // url: "/pass/user/login",
        url: "/pass/auth-serv/sms/sendCode",
        data:{
            phone:phone,
            min:"5"
        },
        method: "post",
    });
}
export function loginReq(phone,code) {
    return request({
        // url: "/pass/user/login",
        url: "/pass/auth-serv/sms/login",
        data:{
            phone:phone,
            code:code
        },
        method: "post",
    });
}
export function zfbLogin() {
    return request({
        // url: "/pass/user/login",
        url: "/pass/auth-serv/alipay/login",
        method: "get",
    });
}



export function goodsList() {
    return request({
        // url: "/pass/user/login",
        url: "/pass/product-serv/goods/list",
        method: "get",
    });
}

//商品详情页
export function getGoodsDetail(gid) {
    console.log("我拿到的+"+gid)
    return request({
        // url: "/pass/user/login",
        url: "/pass/product-serv/goodstwo"+"/"+gid,
        method: "get",
    });
}

//语言
export function getLanguage() {
    return request({
        url: "/pass/other-serv/language/list",
        method: "get",
    });
}

//历史搜索
export function getHistroy() {
    return request({
        url: "/check/other-serv/histroy/list/",
        method: "get",
    });
}
//热门搜索
export function getHot() {
    return request({
        url: "/check/product-serv/goods/sort",
        method: "get",
    });
}
//秒杀
export function getSkillGoods() {
    return request({
        url: "/pass/product-serv/goods/mslist/2",
        method: "get",
    });
}
//大促
export function getbigSaleGoods() {
    return request({
        url: "/pass/product-serv/goods/mslist/1",
        method: "get",
    });
}
//根据商品名搜索
export function getSeachGoods(name) {
    return request({
        url: "/check/product-serv/goods/search",
        params:{
            goodName:name
        },
        method: "get",
    });
}

//根据用户id保存搜索记录
export function putSeachHistroy(goodName) {
    console.log("name"+goodName)
    return request({
        url: "/check/other-serv/histroy",
        data:{
            name:goodName
        },
        method: "put",
    });
}
//通过商品id，颜色id，尺寸id获取库存
export function getInventory(gid,cid,sid) {
    return request({
        url: "/pass/inventory-serv/inventory"+"/"+gid+"/"+cid+"/"+sid,
        // url: "pass/inventory-serv/inventory/1/1/1",
        method: "get",
    });
}
// 根据商品详情id和用户id添加购物车
    export function putCart(gid,cid,sid,num) {
        return request({
            url: "/check/product-serv/goodstwo/",
            data:{
                goodId:gid,
                colorId:cid,
                sizeId:sid,
                count:num,
            },
            method: "put",
        });
    }
//测试
// export function putCart(uid,goodId,img,name,color,size,price,count) {
//         return request({
//             url: "http://43.139.7.123:8080/check/addCart",
//             data:{
//                 uid:uid,
//                 goodId:goodId,
//                 img:img,
//                 name:name,
//                 color:color,
//                 size:size,
//                 price:price,
//                 count:count
//             },
//             method: "put",
//         });
//     }
//秒杀详情
export function getKill() {
    return request({
        url: "/pass/other-serv/activity/list",
        method: "get",
    });
}
//获取购物车商品列表
export function cartGoodsList() {
    return request({
        url: "/check/other-serv/cart/list/",
        method: "get",
    });
}
//获取用户地址列表
export function userAddressList() {
    return request({
        url: "/check/user-serv/user/address/",
        method: "get",
    });
}
//根据商品主表id获取库存量
export function getInventoryAvail() {
    return request({
        url: "/pass/inventory-serv/inventory/avail/1",
        method: "get",
    });
}
//获取分类
export function getCateGroy() {
    return request({
        url: "/pass/inventory-serv/categroy/list",
        method: "get",
    });
}
//查询对应的分类下的商品信息
    export function getCateGroyGoods(cid) {
        return request({
            url: "/pass/product-serv/goods/category"+"/"+cid,
            method: "get",
        });
    }
//立即购买
    export function getBuyGoodsNow(gid,userAddressId,userCouponsId) {
        return request({
            url: "/check/order-serv/orders/",
            data:{
                "goodsTwoId":gid,
                "userAddressId":userAddressId,
                "userCouponsId":userCouponsId
            },
            method: "put",
        });
    }
//秒杀提交订单
export function getBuyKillGoodsNow(gid,userAddressId,userCouponsId) {
    return request({
        url: "/check/order-serv/orders/kill",
        data:{
            "goodsTwoId":gid,
            "userAddressId":userAddressId,
            "userCouponsId":userCouponsId
        },
        method: "put",
    });
}



 //删除优惠券
export function delcoup(cid) {
    return request({
        url: "/check/user-serv/user/usertocoupons"+"/"+cid,
        method: "delete",
    });
}
//购物车--》立即购买
export function getBuyGoods(gid,userAddressId,userCouponsId) {
    return request({
        url: "/check/order-serv/orders/order",
        data:{
            "goodTwoId":gid,
            "userAddressId":userAddressId,
            "userCouponsId":userCouponsId
        },
        method: "put",
    });
}


//初始化优惠券
    export function getBigSalecoup(tid) {
        return request({
            url: "/check/user-serv/coupons/couponslist/"+tid,
            method: "get",
        });
    }
    //查看是否有券
export function getIsHavecoup(aid) {
    return request({
        url: "check/user-serv/user/userOncoup",
        data:
    {
        "activeId":aid,
    }
        ,
        method: "post",
    });
}
//新增优惠券
    export function putCoup(cid) {
        return request({
            url: "/check/user-serv/user/userAddCoupons"+"/"+cid,
            method: "put",
        });
    }

//查询优惠券
export function getAllCoup() {
    return request({
        url: "/check/user-serv/user/coupons",
        method: "get",
    });
}
    //立即购买
    export function buyNow(gid,cid,sid,num) {
        return request({
            url: "/check/product-serv/goodstwo/buyNow",
            data:{
                "goodId":gid,
                "colorId":cid,
                "sizeId":sid,
                "count":num,
            },
            method: "put",
        });
    }
    //秒杀的购买
export function killBuyNow(gid,cid,sid,num) {
    return request({
        url: "/check/product-serv/goodstwo/secondsKill",
        data:{
            "goodId":gid,
            "colorId":cid,
            "sizeId":sid,
            "count":num,
        },
        method: "put",
    });
}
//根据userId清空购物车
export function clearShopCart(goodsTwoId) {
    return request({
        url: "/check/other-serv/cart/cartContent",
        method: "delete",
        data:{
            goodsTwoId:goodsTwoId
        }
    });
}

//根据商品详情id删除单个商品
export function deleteCartGoods(gid) {
    return request({
        url: "/check/other-serv/cart/goodstwoId"+"/"+gid,
        method: "delete",
    });
}
//根据商品详情id修改数量
export function exitGoodsCount(gid,count) {
    return request({
        url: "/check/other-serv/cart/goodstwoCount",
        method: "post",
        data:{
            gid:gid,
            count:count
        }
    });
}
//获取用户订单信息
export function getAllOrder(status) {
    return request({
        url: "/check/user-serv/user/order"+"/"+status,
        method: "get",
    });
}
//添加地址
export function addUserAddress(obj) {
    return request({
        url: "/check/user-serv/user/userAddress",
        method: "put",
        data:{
            addName:obj.name,
            phone:obj.phone,
            region:obj.region,
            detailedAddress:obj.detailedAddress,
            zipCode:obj.zipCode,
            isDefault:obj.isDefault,
            areaCode:obj.areaCode
        }
    });
}
//修改地址
export function editUserAddress(aid,obj) {
    return request({
        url: "/check/user-serv/user/modifyUserAddress",
        method: "post",
        data:{
            id:aid,
            name:obj.name,
            phone:obj.phone,
            region:obj.region,
            detailedAddress:obj.detailedAddress,
            zipCode:obj.zipCode,
            isDefault:obj.isDefault,
            areaCode:obj.areaCode
        }
    });
}
//删除地址
export function deleteUserAddress(aid) {
    return request({
        url: "/check/user-serv/user/remoAddress"+"/"+aid,
        method: "delete",
    });
}
//获取用户信息
export function getMineMessage() {
    return request({
        url: "/check/user-serv/user/userInfo",
        method: "get",
    });
}
//通过订单号和用户id获取订单地址
export function getOrderAddress(uuid) {
        return request({
            url: "/check/order-serv/orders/getOrderAddress",
            method: "post",
            data:{
                uuid:uuid
            }
        });
    }
//支付宝登录返回获取token
export function getzfbToken() {
    return request({
        url: "/pass/auth-serv/alipay/getToken",
        method: "get",
    });
}
//取消订单
export function cancelOrders(orderId) {
    return request({
        url: "/check/orders/cancelOrder/"+orderId,
        method: "post",
    });
}
// //订单模块接口
// export function getAll(data) {
//     return request({
//         url: "/check/order/list",
//         method: "get",
//         data: data,
//     });
// }
// export function getGoodsList(data) {
//     return request({
//         url: "/check/orderGood/" + data,
//         method: "get",
//     });
// }
//
// export function getMenu(data) {
//     return request({
//         url: "/check/menu/menuList",
//         method: "get",
//         data: data,
//     });
// }
// //商品模块接口
// export function getGoods(currentPage,size) {
//     return request({
//         url: "/check/goods/" + currentPage + "/" + size,
//         method: "get",
//     });
// }
//
// export function addGoodInfo(data,config) {
//     return request({
//         url: "/check/goods/addInfo",
//         method: "post",
//         data: data,
//         headers: config.headers
//     });
// }
// export function editGoodInfo(data,config) {
//     return request({
//         url: "/check/goods/editGoodInfo",
//         method: "post",
//         data: data,
//         headers: config.headers
//     });
// }
// export function delGoodInfo(data,config) {
//     return request({
//         url: "/check/goods/" + data,
//         method: "delete",
//     });
// }
// export function getCateGroyGoods(cid) {
//     return request({
//         url: "/pass/product-serv/goods/category"+"/"+cid,
//         method: "get",
//     });
// }


